Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix svg xml parse #127

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

fix svg xml parse #127

wants to merge 4 commits into from

Conversation

mike1pol
Copy link

@mike1pol mike1pol commented Dec 7, 2015

fix svg xml parse on parseIdentify

@codetker
Copy link

codetker commented Jun 8, 2017

I want to know that why the npm version is still five years ago,which remains a bug about svg parsing ‘imagetrick non-conforming drawing primitive definition text-align’. It drove me mad yesterday.

@mike1pol
Copy link
Author

mike1pol commented Jun 8, 2017

@codetker you can use fixed fork https://www.npmjs.com/package/@mikepol/imagemagick

@codetker
Copy link

codetker commented Jun 9, 2017

@mike1pol I am very glad for your timely reply,even though it doesn't works. I use imagemagick to convert the output svg (from draw.io) in other image type, it works if there are no words in the svg chart.
1、To deal with ‘imagetrick non-conforming drawing primitive definition text-align’,I made a very simple svg with words in it.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="121px" height="61px" version="1.1" style="background-color: rgb(255, 255, 255);"><defs/><g transform="translate(0.5,0.5)"><rect x="0" y="0" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(41.5,23.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="36" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 37px; white-space: nowrap; word-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;">都可以</div></div></foreignObject><text x="18" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">科技</text></switch></g></g></svg>

2、An idea came to me that the svg may not stardard ,although it looks well in browsers.So I delete words about 'text-align' to avoid the error.And turns the svg to the bottom.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="121px" height="61px" version="1.1" style="background-color: rgb(255, 255, 255);"><defs/><g transform="translate(0.5,0.5)"><rect x="0" y="0" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(41.5,23.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="36" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 37px; white-space: nowrap; word-wrap: normal; "><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-decoration:inherit;">都可以</div></div></foreignObject><text x="18" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">科技</text></switch></g></g></svg>

It works for imagemagicks and I got my png.A pity that the png is not what I want, some error tips on it, instand of Chineses words.

3、I also tried gm( I saw it in your last commit msg in readme.txt),it doesn't interrupted,but it only convert the part it identified.

4、I tried imagemagick-native, rsvg, imagemagick2 which all calls node-gym,but all of them occurs a problem familiar to nodejs/node-gyp#809. It wastes me a whole afternoon to try to solve the problem but failed.

5、Lastly,I use svgexport to get a luck. I used it before ,but it depends on PhantomJS, which is a quite huge guy. It turns out the svg with Chinese words can be well converted. The process of converting for svgexport is more than 2 seconds, while imagemagick only takes one percent.

So long haven't I written English, it very kind of you to read my poor words. How I wish imagemagic updates and be better and better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants